package ucm;

import java.sql.Connection;
import java.sql.Statement;
import model.Database_Model;
import model.Line_Model;
import model.User_Model;

public class UCRegisterOrders {

    private String name, price, destination, time, gst;
    private User_Model user;
    private Line_Model lm;

    public UCRegisterOrders() {
    }

    public UCRegisterOrders(view.Air_User au) {
        this.user = au.getUserModel();
        this.name = user.getUsername();

        this.lm = au.getLineModel();
        System.out.println(lm.getName());
    }

    public String run() {
        boolean inserted = false;
        try {
            Connection con = new Database_Model().getConnection();
            Statement stmt = con.createStatement();
            stmt.executeUpdate("insert into orders value ('" + name + "','" + lm.getName() + "','" + lm.getPrice() + "')");
            return "Congratulate! ";
        } catch (Exception e) {
            e.printStackTrace();
            return "Denied!";
        }
    }
}
